package com.jf.utils;

import java.awt.*;
import java.awt.font.FontRenderContext;
import java.awt.geom.AffineTransform;
import java.awt.geom.Rectangle2D;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-08-07
 * Time:2:17
 */
public class Util {
    public static int getStringWidth(String str, Font font) {
        AffineTransform atf = new AffineTransform();
        FontRenderContext frc = new FontRenderContext(null, true, true);
        Rectangle2D bounds = font.getStringBounds(str, frc);
        return (int) bounds.getWidth();
    }
}
